package netty.c2;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.concurrent.*;

public class TestJDKFuture {
    static Logger logger = LogManager.getLogger("mylog");
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> future = service.submit(new Callable<Integer>(){

            @Override
            public Integer call() throws Exception {
                logger.debug("执行计算");
                Thread.sleep(1000);
                return 50;
            }
        });
        logger.debug("等待结果");
        logger.debug("结果是{}", future.get());
    }
}
